package com.house.java.util;

import java.sql.Date;

import com.house.java.model.News;
import com.house.java.model.User;

public class UserUtils {

	public void setUser(User user,String fieldName,String fieldValue){
		if(StringUtils.hasLength(fieldValue) && StringUtils.hasLength(fieldName)){
			setFieldForUser(user, fieldName, fieldValue);
		}
	}
	
	/**
	 * 根据属性名设置NewHouse的属性值
	 * @param house
	 */
	public void setFieldForUser(User user,String fieldName,String fieldValue){
		if("userName".equals(fieldName)){
			user.setUserName(fieldValue);
		}else if ("id".equals(fieldName)) {
			user.setId(Long.valueOf(fieldValue));
		}else if ("password".equals(fieldName)) {
			user.setPassword(EncryptUtil.md5Encrypt(fieldValue));
		}else if ("trueName".equals(fieldName)) {
			user.setTrueName(fieldValue);
		}else if ("telephone".equals(fieldName)) {
			user.setTelephone(fieldValue);
		}else if ("countryCode".equals(fieldName)) {
			user.setCountryCode(Integer.valueOf(fieldValue));
		}else if ("provinceCode".equals(fieldName)) {
			user.setProvinceCode(Integer.valueOf(fieldValue));
		}else if ("cityCode".equals(fieldName)) {
			user.setCityCode(Integer.valueOf(fieldValue));
		}else if ("userType".equals(fieldName)) {
			user.setUserType(Integer.valueOf(fieldValue));
		}else if ("newHouseAuth".equals(fieldName)) {
			user.setNewHouseAuth(Integer.valueOf(fieldValue));
		}else if ("secondHouseAuth".equals(fieldName)) {
			user.setSecondHouseAuth(Integer.valueOf(fieldValue));
		}else if ("newsAuth".equals(fieldName)) {
			user.setNewsAuth(Integer.valueOf(fieldValue));
		}
	}
}
